Creating Your Own Toolbox Items Using Built-In Classes

You can create your own toolbox items to allow users to create instances of a custom shape or node type that you’ve defined. Toolbox items must be instances of DiagramNodeTool or DiagramConnectionTool.

For a node tool, you will need to set three properties on the DiagramNodeTool:

For a connection tool, you will need to set two properties on the DiagramConnectionTool:

CopyCustom toolbox items
<local:CarConnectionBuilder x:Key="TowingConnector" CarConnectionKind="Towing" />

<ms:DiagramNodeTool Builder="{ms:BuilderType local:CarNodeBuilder}">
  <ms:DiagramNodeTool.CursorVisual>
    <TextBlock Text="Car" />
  </ms:DiagramNodeTool.CursorVisual>
  <TextBlock Text="Car" />
</ms:DiagramNodeTool>

<ms:DiagramConnectionTool Builder="{StaticResource TowingConnector}">
  <Path Style="{StaticResource ConnectionPathStyle}" Data="M 0 0 L 1 1" />
</ms:DiagramConnectionTool>

It is also common to provide a tooltip by setting the ToolTip property.

Toolbox items created in this way have the same behaviour as the standard toolbox items: in particular, they can be used in the same ways (drag, charged cursor, dragging of charged cursor) described above.

For a worked example, see the CustomNodeType sample.

Creating Your Own User Interface

You can of course create a completely custom user interface and have it call the diagramming API to create new nodes:

CopyC#
IDiagramModel diagram = GetDiagram();  // e.g. diagramSurface.Diagram
StartNode node = CreateStartNode(someText, someBounds);
diagram.Nodes.Add(node);